package Flap::App::Cmd::Tool::Controller::Root;
use Flap qw/-b Flap::App::Cmd::Controller -m -s -w/;

sub generate {
    my($self, $c) = @_;
    my $proj = $c->project;
    my $dir = $c->project_root.'/generate';
    my $ls = $proj->OS->ls($dir) || die "$!($dir)";
    my $ss = join(' or ', map{ substr($_, 2) } @$ls);
    my $u = 'usage: run.pl generate SOURCE NAME [PATH]';
    
    my($src, $name, $dst) = $c->argv;
    die "No SOURCE($ss)\n$u" if !$src;
    die qq{Invalid SOURCE: "$src" ($ss)\n$u} if !grep{ $_ eq "My$src" } @$ls;
    die "No NAME\n$u\n" if !$name;
    
    $dst ||= $src eq 'Project' ? $name : $c->project_root."/apps/$name";
    $proj->generate("My$src", $name, $dst);
}

sub sweep {
}

1;
